import request from '@/utils/request'
import { Login } from '@/types/api'
import { User, ResType, Dept } from '@/types/api'

export default {
  login(params: Login.email) {
    return request.post('/user/login/email/password', params, { showLoading: false, showError: true })
  },
  getUser8Email(userEmail: string) {
    // 使用用户邮箱查询获取用户信息
    return request.get<ResType<User.userInfo>>(`/user/get8Email/${userEmail}`)
  },
  getUserList() {
    return request.get<ResType<User.userInfo[]>>('/user/list')
  },
  insertUser(user: User.userInfo) {
    return request.post<ResType<User.userInfo>>('/user/insert', user)
  },
  saveUser(user: User.userInfo) {
    // 无则新增，有则修改
    return request.post<ResType<User.userInfo>>('/user/save', user)
  },
  deptSelectAll() {
    return request.post<ResType<Dept.DeptItem[]>>('/department/selectAll')
  }
}
